package com.neu.service.impl;

import java.util.ArrayList;

import com.neu.dao.IworkerDao;
import com.neu.dao.impl.WorkerDao;
import com.neu.pojo.Worker;
import com.neu.service.IworkerService;

public class WorkerService implements IworkerService {
	private IworkerDao workerDao = WorkerDao.getInstance();
	
	private static WorkerService workerService = new WorkerService();
	private WorkerService() {}
	public static WorkerService getInstance() {
		return workerService;
	}
	
	public boolean add(Worker w) {
		return workerDao.add(w);
	}
	
	//注册
	@Override
	public boolean login(Worker w) {
		Worker worker = workerDao.search(w);
		if(worker == null) {
			return false;
		}else if(worker.getPassword().equals(w.getPassword())) {
			return true;
		}else {
			return false;
		}
	}
	
	//getAll
	@Override
	public ArrayList<Worker> list(){
		return workerDao.list();
	}
	
	//删除
	@Override
	public boolean delete(Worker w) {
		return workerDao.delete(w);
	}
	
	public boolean cover(Worker w) {
		return this.workerDao.cover(w);
	}
	
	public Worker search(Worker worker) {
		return this.workerDao.search(worker);
	}
}
